package com.itboye.jmsfhz.app.adapter;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.itboye.config.GlobalConfig;
import com.itboye.core.utils.XImageLoader;
import com.itboye.jmsfhz.R;
import com.lfh.commentdemo.bean.AppModelNewsBean;

public class GridViewAdapter extends BaseAdapter {
	Activity context;
	AppModelNewsBean list;

	public GridViewAdapter(Activity context, AppModelNewsBean list) {
		this.context = context;
		this.list = list;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.getList() == null ? 0 : list.getList().size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		// return list.get(position).getId();
		return list.getList().get(position).getId();
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHouder houder;
		if (convertView == null) {
			houder = new ViewHouder();
			convertView = LayoutInflater.from(context).inflate(
					R.layout.item_gongao_time, null);
			houder.leit = (ImageView) convertView.findViewById(R.id.imgtop);
			houder.tvleit = (TextView) convertView
					.findViewById(R.id.tvBiaoqian);
			convertView.setTag(houder);
		} else {
			houder = (ViewHouder) convertView.getTag();
		}
		
		XImageLoader.load(GlobalConfig.JIUYE
				+ list.getList().get(position).getMain_img(), houder.leit);
		 houder.tvleit.setText(list.getList().get(position).getPost_title());
		 System.out.println("title"+list.getList().get(position).getPost_title());
		return convertView;
	}

	class ViewHouder {
		ImageView leit;
		ImageView right;
		TextView tvleit;
		TextView tvright;
	}

}
